home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Evatac Software / Preditor 3.0 / Samples / Source Sample.cp < prev   
Text File  |  1995-11-05  |  3KB  |  111 lines

  1. /******************************************************************************
  2.  CToolsDir.c
  3.  
  4.                             The ToolsDir Class
  5.     
  6.         Director for the Tools tear-off menu
  7.  
  8.     SUPERCLASS = CTearOffMenu
  9.     
  10.     Copyright © 1989 Symantec Corporation. All rights reserved.
  11.     
  12.     TCL 2.0 changes:
  13.     [
  14.         - replaced calls to I-methods with constructor calls.
  15.     ]
  16.  
  17.  ******************************************************************************/
  18.  
  19. #include "Global.h"
  20. #include "CCharGrid.h"
  21. #include "CSelectorMDEF.h"
  22. #include "CToolsDir.h"
  23. #include "ArtClassCmds.h"
  24. #include "CWindow.h"
  25.  
  26. /*** Global Variables ***/
  27.  
  28. extern CBureaucrat    *gGopher;            /* First in line to get commands    */
  29.  
  30. extern short        gPaintTool;            /* The current painting tool        */
  31.  
  32. /*** Class Contstants ***/
  33.  
  34. #define        WINDtools        1003        /* Resource ID for tools window        */
  35.  
  36.  
  37. /******************************************************************************
  38.  CToolsDir
  39.  
  40.         Initialize a ToolsDir object
  41.  ******************************************************************************/
  42.  
  43. CToolsDir::CToolsDir(CApplication *aSupervisor) : CTearOffMenu(WINDtools)
  44. {
  45.     CCharGrid        *theTools;
  46.     CSelectorMDEF    *theSelectorMDEF;
  47.     short            width;
  48.     short            height;
  49.     Rect            sizeRect;
  50.  
  51.     itsWindow->SetActClick(TRUE);
  52.                             
  53.     theTools = new CCharGrid(MENUtools, itsWindow, this);
  54.     
  55.     theTools->gridOn = TRUE;
  56.     
  57.     theTools->Activate();
  58.     
  59.     theTools->selection = gPaintTool;
  60.  
  61.                                         /* Make window same size as Tools    */
  62.                                         /*   without lines on the edges        */
  63.     theTools->GetLengths(&width, &height);
  64.     SetRect(&sizeRect, width-1, height-1, width, height);
  65.     itsWindow->SetSizeRect(&sizeRect);
  66.     itsWindow->ChangeSize(width-1, height-1);
  67.     
  68.     itsPane = theTools;
  69.     SetRect(&margins, 1, 10, 1, 1);        /* One pixel frame with a 10 pixel    */
  70.                                         /*   drag bar on the top side        */
  71.  
  72.     theSelectorMDEF = new CSelectorMDEF(MENUtools, itsPane, this);
  73.     
  74.     itsWindow->MoveOffScreen();            /* Put window out of sight until    */
  75.     itsWindow->Select();                /*   needed                            */
  76. }
  77.     
  78.  
  79. /******************************************************************************
  80.  DoCommand {OVERRIDE}
  81.  
  82.         Handle commands for the selection of a tool
  83.  ******************************************************************************/
  84.  
  85. void    CToolsDir::DoCommand(
  86.     long        theCommand)
  87. {
  88.     Str255            commandStr;
  89.  
  90.     if (HiShort(-theCommand) == ((CCharGrid*)itsPane)->GetCommandBase()) {
  91.                                         /* Item from Tools was selected        */
  92.         gGopher->DoCommand(theCommand);                                
  93.     
  94.     } else {
  95.         CTearOffMenu::DoCommand(theCommand);
  96.     }
  97. }
  98.     
  99.  
  100. /******************************************************************************
  101.  SelectTool
  102.  
  103.         Set the current tool selection
  104.  ******************************************************************************/
  105.  
  106. void    CToolsDir::SelectTool(
  107.     short        theTool)
  108. {
  109.     itsPane->Prepare();
  110.     ((CCharGrid*)itsPane)->ChangeSelection(theTool);
  111. }